<html>
 <head></head>
 <body>
  {include file=&quot;header/index&quot; /} 
  <meta charset="UTF-8" /> 
  <style>
    .form-control {
            height: 33px;
    }
    </style>  
  <div class="container  privilegeUserList pb40"> 
   <h2 class="list-title">管理员列表</h2> 
   <div class="addUser"> 
    <div class="row"> 
     <div class="col-lg-2 col-md-2 	col-sm-3"> 
      <a href="{:url('Users/addUser')}" class="btn btn-default addUser-btn">添加用户</a> 
     </div> 
     <form action="{:url('Users/index')}" method="get"> 
      <div class="col-lg-4  col-md-4 	col-sm-6"> 
       <div class="input-group"> 
        <input type="text" name="account" class="form-control borBox" placeholder="输入需要查询的用户名" value="&lt;?php if(isset($_REQUEST['account'])){echo $_REQUEST['account'];} ?&gt;" /> 
        <span class="input-group-btn"> <button class="btn btn-primary borBox" type="submit">搜索</button> </span> 
       </div> 
       <!-- /input-group --> 
      </div> 
     </form> 
     <!-- /.col-lg-6 --> 
    </div> 
    <!-- /.row --> 
   </div> 
   <div class="table-responsive mt40"> 
    <table class="table table-bordered"> 
     <thead> 
      <tr> 
       <th>ID</th> 
       <th>管理员名称</th> 
       <th>头像</th> 
       <th>管理员角色</th> 
       <th>登录次数</th> 
       <th>上次登录ip</th> 
       <th>上次登录时间</th> 
       <th>真实姓名</th> 
       <th>状态</th> 
       <th>操作</th> 
      </tr> 
     </thead> 
     <tbody>
       {foreach $data as $v} 
      <tr> 
       <td>{$v.id}</td> 
       <td>{$v.account}</td> 
       <td><img class="user-img" src="{:Config('IMAGES_PATH')}{$v.avatar_img}" /></td> 
       <td>{$v.title}</td> 
       <td>{$v.loginnum}</td> 
       <td>{$v.last_login_ip}</td> 
       <td>{:date('Y-m-d H:i:s',$v.last_login_time)}</td> 
       <td>{$v.name}</td> 
       <td> 
        <!--?php if($v['is_admin'] != 1){ ?--> {if condition=&quot;$v['status'] eq 1&quot;} 
        <div id="zt8" onclick="role_state(this,{$v.id})">
         <span class="label label-info">开启</span>
        </div> {else /} 
        <div id="zt8" onclick="role_state(this,{$v.id})">
         <span class="label label-danger">关闭</span>
        </div> {/if} 
        <!--?php }?--> </td> 
       <td> 
        <!--?php if($v['is_admin'] != 1){ ?--> <a href="{:url('Users/updateUser',array('id'=&gt;$v['id']))}" class="btn btn-primary btn-xs"> <i class="fa fa-paste"></i> 编辑</a>&nbsp;&nbsp; <a href="javascript:;" onclick="roleDel(this,{$v.id})" class="btn btn-danger btn-xs"> <i class="fa fa-trash-o"></i> 删除</a> 
        <!--?php }?--> </td> 
      </tr> {/foreach} 
     </tbody> 
    </table> 
   </div> 
   <p class="fr">第1页,共1页</p> 
  </div>  
  <script>
	//状态开启关闭
	function role_state(obj,id) {
		$.post("{:url('Users/userEditStatus')}",{id:id},function(e){
			if(e.code == '1'){
				layer.msg(e.msg, {icon: 1,time: 2000});
				if($(obj).find("span").hasClass("label-info")) {
					$(obj).find("span").addClass("label-danger")
					$(obj).find("span").removeClass("label-info");
					$(obj).find("span").text("关闭");
				} else {

					$(obj).find("span").removeClass("label-danger")
					$(obj).find("span").addClass("label-info");
					$(obj).find("span").text("开启")

				}
			}else{
       			layer.msg(e.msg,{icon:0,shade:0.1});
       			return false;
			}
		},'json')
	}


	//删除
	function roleDel(obj,id) {
		layer.alert('确认删除此条记录吗?', {
			btn: ['确认', '取消'], //按钮

		}, function() {
			$.post("{:url('Users/delUser')}",{id:id},function(e){
				if(e.code == '1'){
					layer.open({content: e.msg,time: 2000});
					$(obj).parents("tr").remove()
				}else{
					layer.open({content: e.msg,time: 2000});
				}
			},'json');
		});
	}



	</script> 
 </body>
</html>